package com.qj.yantaishan.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.qj.yantaishan.common.core.domain.R;
import com.qj.yantaishan.domain.Permission;
import com.qj.yantaishan.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("yantaishan/permission")
public class PermissionController {
    @Autowired
    private IPermissionService permissionService;

    /**
     * 获取全部权限
     *
     * @return
     */
    @GetMapping("all")
    public R getPermissionAll() {
        List<Permission> permissionsAll = permissionService.selectPermissionAll();
        return R.ok(permissionsAll);
    }

    @GetMapping("my")
    public R getMyPermission() {
        List<String> permissionList = StpUtil.getPermissionList();
        List<Map<String, Object>> mapList = permissionService.getPermissionListByManageId(StpUtil.getLoginId());
        return R.ok(mapList);
    }


}
